home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / Z4PFBLD.C < prev    next >
C/C++ Source or Header  |  1995-05-02  |  4KB  |  144 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    z4pfbld.c
  5. //   Title:    9-Digit ZIP Code Directory -- on CD-ROM
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //    This module contains the program entry point for
  24. //
  25. //    The code in this module may be written in C++ or C.
  26. //
  27. //    This module is portable to:
  28. //        DOS 3.X+
  29. //        MS Windows 3.X+
  30. //        OS/2 2.X+
  31. //        OS/2 2.0 PM
  32. //
  33. //    The following compilers are supported:
  34. //        MSC 6.0A
  35. //        MSC/C++ 7.0
  36. //        Borland C++ 3.1 for DOS
  37. //        Borland C++ 1.0 for OS/2 2.X
  38. //
  39. //----------------------------------------------------------------------------
  40. #include <z4.h>
  41.  
  42.  
  43. //----------------------------------------------------------------------------
  44. //    Stack size
  45. //----------------------------------------------------------------------------
  46. #if COMPILER_BORLAND && (OS_DOS || OS_WINDOWS)
  47. unsigned _stklen = 0x4000;
  48. #endif
  49.  
  50.  
  51. //----------------------------------------------------------------------------
  52. //    Globals
  53. //----------------------------------------------------------------------------
  54.  
  55. //
  56. // A useless string which is simply embedded in the executable.
  57. //
  58. PSZ __pszCredits__ = "Written by John M Weeder, 1993";
  59.  
  60.  
  61. //
  62. //    This should contain a program description which will be displayed as
  63. //    part of the program's help text.
  64. //
  65. static PCSZ pcszDescription =
  66.     "This program builds the POF database. This database is only used\n"
  67.     "during the file build process.";
  68.  
  69. //
  70. //    Program command line options
  71. //
  72. static DATACFG dcfg;
  73. static BOOL fSort = FALSE;
  74. static BOOL fCompress = FALSE;
  75. static BOOL fIndex = FALSE;
  76. static BOOL fCheck = FALSE;
  77. static CHAR szConfig[MAX_PATH] = "z4pf";
  78. static BS_CMDOPT acmdopt[] =
  79.     {
  80.     { "CHECK",        (PVOID)&fCheck,        CMDOPT_TRUE,             "Validate CRC codes."},
  81.     { "COMPRESS",    (PVOID)&fCompress,    CMDOPT_TRUE,             "Compress data file."},
  82.     { "INDEX",        (PVOID)&fIndex,        CMDOPT_TRUE,             "Index data file."},
  83.     { "SORT",       (PVOID)&fSort,         CMDOPT_TRUE,             "Sort stripped data file."},
  84.     { "config",     (PVOID)szConfig,        CMDOPT_FILESPEC(80), "Configuration file name."},
  85.     BS_CMDOPT_NULL,
  86.     };
  87.  
  88.  
  89. //----------------------------------------------------------------------------
  90. //   Description:    main() - Program entry point
  91. //    Parameters:    Standard C parameters
  92. //       Returns:    DOS return code.
  93. //----------------------------------------------------------------------------
  94. int main(int argc, char **argv)
  95. {
  96. static BS_CFG cfg = CFG_DFT;
  97.     int retval = 99;
  98.  
  99.     //
  100.     //    Initialize base library
  101.     //
  102.     BaseLibraryInitialize(argc, argv, &cfg);
  103.     BaseTitle("$Revision:  93.1  $", __DATE__, __TIME__, "ZIP+4 POF File Build");
  104.     if (!BaseTitleHelp(acmdopt, pcszDescription,NULL))
  105.         return 99;
  106.     DioSetDataPath(getenv("DATA"));
  107.     if (!DataConfigRead(szConfig, &dcfg))
  108.         {
  109.         Output("Failed reading configuration file.\n");
  110.         goto ERROR_EXIT;
  111.         }
  112.     if (fSort)
  113.        if (!DataSort(&dcfg))
  114.            {
  115.            Output("Failed sorting delimited data file.\n");
  116.            goto ERROR_EXIT;
  117.            }
  118.     if (fCompress)
  119.        if (!DataCompress(&dcfg, Z4PFCompress, 0))
  120.            {
  121.            Output("Failed compressing delimited data file.\n");
  122.            goto ERROR_EXIT;
  123.            }
  124.     if (fIndex)
  125.         if (!DataIndex(&dcfg, Z4PFIndex))
  126.            {
  127.            Output("Failed indexing CS data file.\n");
  128.            return 99;
  129.            }
  130.     if (fCheck)
  131.         if (!DioCheck(dcfg.szData))
  132.            {
  133.            Output("Failed verifying data file.\n");
  134.            return 99;
  135.            }
  136.     retval = 0;
  137. ERROR_EXIT:
  138.     DioCloseAll();
  139.     return retval;
  140. }
  141. //----------------------------------------------------------------------------
  142. //------------------------------- End of File --------------------------------
  143. //----------------------------------------------------------------------------
  144.